<?php 

Class photoModel extends appModel
{
	
    function get_photo_list($page=1,$id,$page_size=99)
    {
    	$listPage=array('data'=>'','pageLink'=>'');
    	if($id)
    	{
    	
    	
    	$result=$this->show_page(" SELECT id,original_pic,abstract,title,middle_pic FROM ".$this->table('album_photos').' WHERE cat_id='.$id." ORDER BY ordering DESC,id",$page,$page_size);
    		
    	if($result)
    	{
    		foreach($result['result'] as $k=>$v)
    		{
    			$result['result'][$k]['title']=hy_dig_filter($v['title']);
    			$result['result'][$k]['abstract']=hy_dig_filter($v['abstract']);
    			if(REWRITE==1)
    			{
    				$result['result'][$k]['url']="/p/".$v['id'].".html";
    			}
    			else
    			{
    			  $result['result'][$k]['url']="index.php?g=home&m=photo&a=view&id=".$v['id'];
    			}
    		}
    		 
    	}
    	 
    	
    	$listPage['pagelink']=$result['page'];
	    $listPage['data']=$result['result'];
	   
    	}
    	return $listPage;
    }
   public function get_photo($id)
   {
   	$sql="SELECT a.original_pic,a.title FROM ".$this->table('album_photos')." as a  WHERE a.id = '".$id."'";
    $result=$this->getRow($sql);
    $result['title']=hy_dig_filter($result['title']);
    return $result;
   }
   public function photo_cat($id)
	{
		
		if($id)
		{
			$sql="SELECT a.cat_id,c.code FROM ".$this->table('album_photos')." as a LEFT JOIN ".$this->table('category')." as c ON a.cat_id=c.id WHERE a.id = '".$id."'";
			return $this->getRow($sql);
		}
	}
    
	
}